<?php
/*
 * inc-login.php
 * Retral/CSCD494 Winter 2009
 * Eastern Washington University
 *
 * File Description:
 * Login page. Contains two forms: one for students, one for faculty/administrators.
 * By default is set to show accordian for admin/faculty
 * To change this edit the 'ld' GET parameter
 * 
 * Other:
 * - Uses Prototype 1,5 (does not work correctly with 1,6)
 * - Accordian from stickmanlabs.com and adapted for this page
 */
?>
<!-- accordion adapted from stickmanlabs.com -->

	<script type="text/javascript" src="scriptaculous/prototype.js"></script>
	<script type="text/javascript" src="scriptaculous/effects.js"></script>
	<script type="text/javascript" src="scriptaculous/accordion.js"></script>
	<script type="text/javascript">
	
<?php

	// Toggle these values to have either admin/faculty (default) or student come up first.
	if (isset($_GET['ld']) && $_GET['ld'] == 1)
		$loadTab = 1;
	else
		$loadTab = 0;
	?>
		
		function loadAccordions() {			
			var bottomAccordion = new accordion('vertical_container');

			bottomAccordion.activate($$('#vertical_container .accordion_toggle')[<?php echo $loadTab; ?>]);
		}
		
		
	</script>	
	<script type="text/javascript">Event.observe(window, 'load', loadAccordions, false);</script>
	<style type="text/css" >
		
		/*
			Vertical Accordions
		*/
		
		.accordion_toggle {
			display: block;
			width: 350px;
			height:20px;
			background-color:#880803;
			padding: 0 10px 0 10px;
			line-height: 20px;
			color: #ffffff;
			font-size: 12px;
			border-bottom: 1px solid #330000;
			cursor: pointer;
			margin: 0 0 0 0;
		}
		
		.accordion_toggle_active {
			background-color:#996633
			color: #ffffff;
			border-bottom: 1px solid #660000;
		}
		
		.accordion_content {
			padding-left:10px;
			padding-top:8px;
			padding-bottom:8px;
			background-color: #ffffff;
			color: #444444;
			overflow: hidden;
		}
			
			.accordion_content h2 {
				margin: 15px 0 5px 10px;
				color: #AA3300;
			}
			
			.accordion_content p {
				line-height: 150%;
				padding: 5px 10px 15px 10px;
			}
			
		.vertical_accordion_toggle {
			display: block;
			height: 20px;
			width: 600px;
			background-color:#333333;
			padding: 0 10px 0 10px;
			line-height: 20px;
			color: #ffffff;
			font-size: 12px;
			border-bottom: 1px solid #000000;
			cursor: pointer;
			margin: 0 0 0 0;
		}

		.vertical_accordion_toggle_active {
			background-color:#996633;
			color: #ffffff;
			border-bottom: 1px solid #000000;
		}

		.vertical_accordion_content {
	
			background-color: #ffffff;
			color: #444444;
			overflow: hidden;
		}

			.vertical_accordion_content h2 {
				margin: 15px 0 5px 10px;
				color: #0099FF;
			}

			.vertical_accordion_content p {
				line-height: 150%;
				padding: 5px 10px 15px 10px;
			}
  			
					
    /* Container styling*/
    #horizontal_container {
      margin: 20px auto 20px auto;
      width: 680px;   
      height: 100px;    
    }
    
    #vertical_nested_container {
      margin: 20px auto 20px auto;
      width: 620px;
    }
	</style>
	


<span class="header-text">LOGIN</span><br>

<?php
if (isset($_GET['failed']))
{
	echo "<span style=\"color:red;font-weight:bold;\">Error: Login Unsuccessful</span><br>";
}
?>
<div id="container">
    <h1>Login</h1>
	<div id="vertical_container" >
		<h1 class="accordion_toggle">Faculty</h1>
			<div class="accordion_content">   
				<form action="login.php" method="POST">
					<input type="hidden" id="ape_user" name="ape_user" value="1"/>
                    <table>
					<tr><td>First Name: </td><td> <input name="fname" id="fname" type="text"><br></td></tr>
					<tr><td>Last Name: </td><td><input name ="lname" type="text"><br></td></tr>
					<tr><td>Password: </td><td><input name="passwd" type="password"><br></td></tr>
					<tr><td><input type="submit"  class="button" value="Login"></td></tr>
                    </table>
				</form>
			</div>
		
		<h1 class="accordion_toggle">Students</h1>
		<div class="accordion_content">
			<form action="login.php" method="POST">
				<input type="hidden" id="student_user" name="student_user" value="1"/>
				<table>
                
				<tr><td>Student ID: </td><td><input name="sid" id="sid" type="text"><br></td></tr>
				<tr><td>Password: </td><td><input name="passwd" type="password"><br></td></tr>
				
				<tr><td><input type="submit" class="button" value="Login"></td></tr>
                </table>
			</form>
        </div>
	</div> <!--end vertical container -->
</div>	<!--end container-->

	<?php
			if ($loadTab == 0) //load staff/faculty login
				$focusStr= "document.getElementById('fname').focus();";
			else if ($loadTab == 1)
				$focusStr= "document.getElementById('sid').focus();";
				
			echo "<script type=\"text/javascript\">$focusStr</script>";
			?>